package br.consultorio.digital.modelo.entidade;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import br.consultorio.digital.R;

public class AgendaAdapter extends BaseAdapter {

	private Context context;
	private List<Object> pList;

	public AgendaAdapter(Context context, List<Object> statelist) {
		this.context = context;
		this.pList = statelist;
	}

	public int getCount() {
		return pList.size();
	}

	public Object getItem(int position) {
		return pList.get(position);
	}

	public long getItemId(int position) {
		return ((Agenda) pList.get(position)).getId_agenda();
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		Agenda a = (Agenda) pList.get(position);

		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View view = inflater.inflate(R.layout.agendaitem, null);

		TextView nmMedico = (TextView) view
				.findViewById(R.idAgendaItem.nmMedico);

		nmMedico.setText(a.getMedico().getNm_medico());

		TextView dtAgenda = (TextView) view
				.findViewById(R.idAgendaItem.dtAgenda);

		dtAgenda.setText(a.getDt_agenda());

		TextView hrAgenda = (TextView) view.findViewById(R.idAgendaItem.hrAgenda);

		hrAgenda.setText(a.getNr_hora() + "");

		return view;
	}
}
